import request from '/@/utils/request'

export async function login(data: object): Promise<any> {
  return request({
    url: '/api/auth/loginByPassword',
    method: 'post',
    data,
  })
}

export function getUserInfo() {
  return request<{
    username: string
    avatar: string
    roles: string[]
    permissions: string[]
  }>({
    url: '/api/user/profile',
    method: 'get',
  })
}

export function getPermCode() {
  return request<string[]>({
    url: '/api/role/getPermCode',
    method: 'get',
  })
}

export function logout() {
  return request({
    url: '/api/auth/logout',
    method: 'get',
  })
}

export function register(data: any) {
  return request({
    url: '/register',
    method: 'post',
    data,
  })
}
